﻿package com.nielsen{
	public class ggClient {
		private var _userClient:Object;
		private var _flvName:String;
		private var _videoInfo:String;
		private var _ggNetStream:*;

		public function ggClient( userClient:Object, flvName:String, videoInfo:String, ggNetStream:*):void {
			_userClient=userClient;
			_flvName=flvName;
			_videoInfo=videoInfo;
			_ggNetStream=ggNetStream;
		}

		public function asyncError( info:Object ):void {
			// Return control to program
			if (_userClient.asyncError!=null) {
				_userClient.asyncError( info );
			}
		}

		public function ioError( info:Object ):void {
			// Return control to program
			if (_userClient.ioError!=null) {
				_userClient.ioError( info );
			}
		}

		public function netStatus( info:Object ):void {
			// Return control to program
			if (_userClient.netStatus!=null) {
				_userClient.netStatus( info );
			}
		}

		public function onCuePoint( info:Object ):void {
			// Return control to program
			if (_userClient.onCuePoint!=null) {
				_userClient.onCuePoint( info );
			}
		}

		public function onImageData( info:Object ):void {
			// Return control to program
			if (_userClient.onImageData!=null) {
				_userClient.onImageData( info );
			}
		}

		public function onMetaData( info:Object ):void {
			if (info.title!=null&&info.title!=""&&_videoInfo.indexOf("<title>")==-1) {
				_videoInfo+="<title>"+info.title+"</title>";
			}

			// Catch onMetaData call, send needed info to Glance Guide  
			ggCom.getInstance().PM( "E3", info, _flvName, _videoInfo );

			// Reset client to userClient
			_ggNetStream.client=_userClient;

			// Return control to program
			if (_userClient.onMetaData!=null) {
				_userClient.onMetaData( info );
			}
		}

		public function onPlayStatus( info:Object ):void {
			// Return control to program
			if (_userClient.onPlayStatus!=null) {
				_userClient.onPlayStatus( info );
			}
		}

		public function onTextData( info:Object ):void {
			// Return control to program
			if (_userClient.onTextData!=null) {
				_userClient.onTextData( info );
			}
		}
	}
}